package model.battle 
{
	import constant.CampConst;
	import model.unit.AbsUnit;
	/**
	 * ...
	 * @author Kylin206
	 */
	public class Army 
	{
		private static var _lArmy:Army;
		private static var _rArmy:Army;
		
		private var _camp:uint = 0;
		private var units:Object;
		
		public function Army(camp:uint)
		{
			this._camp = camp;
			units = new Object();
			
			trace("create Army", this);
		}
		
		static public function init():void
		{
			_lArmy = new Army(CampConst.LEFT);
			_rArmy = new Army(CampConst.RIGHT);
		}
		
		static public function get lArmy():Army 
		{
			return _lArmy;
		}
		
		static public function get rArmy():Army 
		{
			return _rArmy;
		}
		
		public function addUnit(unit:AbsUnit):void
		{
			var id:String = String(unit.id);
			
			this.units[id] = unit;
		}
		
		public function getUnit(unitID:uint):AbsUnit
		{
			return null;
		}
		
		public function sort():Array
		{
			var arr:Array = new Array();
			
			for (var i:String in this.units)
			{
				arr.push(units[i]);
			}
			return arr;
		}
		
		/**
		 *  最前方的单位
		 * @return
		 */
		public function getforeUnit(parm:uint = 0):AbsUnit
		{
			return null;
		}
		
		public function get camp():uint 
		{
			return _camp;
		}
		
		public function toString():String 
		{
			return "[Army camp=" + camp + "]";
		}
	}

}